<?
//根据传递的nid，获取该条数据的所有内容
//设置需要搜索的表格的前缀后缀

$table=$table_Prefix.$sys_list_table;
$_nid = $_REQUEST ['nid'];
$detail=select_one_line_all_items($table,"nid= '".$_nid."'");





  
//设置需要搜索的表格的前缀后缀
$table=$table_Prefix."relation";


//开始读取所有的detail对term数据

//echo "当前数据nid".$trans_nid;
//echo "<br/>";

$query = mysql_query("SELECT * FROM $table where detail_nid = '$trans_nid' and belong is NULL "); 

while($row = mysql_fetch_array($query))
  {
  $relation_detail_nid[]    =$row['detail_nid'];
  $relation_term_nid[]      =$row['term_nid'];
  $relation_nid[]           =$row['nid'];
  }

$query = mysql_query("SELECT * FROM $table where detail_nid = '$trans_nid' and belong = 'brand' "); 

while($row = mysql_fetch_array($query))
  {
  $brand_detail_nid[]    =$row['detail_nid'];
  $brand_term_nid[]      =$row['term_nid'];
  $brand_nid[]           =$row['nid'];
  }
 
 
 $query = mysql_query("SELECT * FROM $table where detail_nid = '$trans_nid' and belong = 'shop' "); 

while($row = mysql_fetch_array($query))
  {
  $shop_detail_nid[]    =$row['detail_nid'];
  $shop_term_nid[]      =$row['term_nid'];
  $shop_nid[]           =$row['nid'];
  }

$query = mysql_query("SELECT * FROM ".$table_Prefix."detail_relation where goods_id = '$trans_nid'"); 

$i = 0;
while($row = mysql_fetch_assoc($query))
{
   
   $detail_relation_list_arr[] = $row['detail_id'];
   
   $brand_info = select_one_line_all_items($table_Prefix . "detail" , ' nid ='.$row['detail_id']);
   
   $detail_relation_list_json[$i]['title'] = $brand_info['name'];
   $detail_relation_list_json[$i]['value'] = $brand_info['nid'];
  
  $i++;
}

$detail_relation_list = implode("','",$detail_relation_list_arr);

$detail_relation_list = "'".$detail_relation_list."'";



$query = mysql_query("SELECT * FROM ".$table_Prefix."detail where nid in ($detail_relation_list)"); 

while($row = mysql_fetch_assoc($query))
{
   $detail_relation_detail[$row['nid']]['name'] =$row['name'];
   $detail_relation_detail[$row['nid']]['model'] =$row['model'];
   $detail_relation_detail[$row['nid']]['belong'] =$row['belong'];
}

$type_list  = select_lines_all_items($table=$table_Prefix.'plate','nid desc'," mid != 'index'" );

foreach($type_list as $key=>$val){
		$new_plate_list[$val['mid']]['name'] = $val['name'];
		$new_plate_list[$val['mid']]['mid'] = $val['mid'];
	}


$json_data = '';
foreach($detail_relation_list_arr as $key=>$value){
	
	$detail_relation[$key]['value'] = $value;
	$detail_relation[$key]['title'] = $detail_relation_detail[$value]['name'].$detail_relation_detail[$value]['model'].'['.$new_plate_list[$detail_relation_detail[$value]['belong']]['name'].']';
	
	
}

$json_data = json_encode($detail_relation);


$detail_relation_list_json = json_encode($detail_relation_list_json);



$product_attr = array();
$query = mysql_query("SELECT * FROM ".$table_Prefix."product_attr where detail_nid = $trans_nid "); 

while($row = mysql_fetch_assoc($query))
{
   $product_attr[$row['nid']] =$row;
}


?>


